<%-- 
    Document   : index
    Created on : 23/05/2012, 11:10:58
    Author     : luiz.perez
--%>

<%@page import="java.util.Calendar"%>
<%@page import="java.sql.ResultSet"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="style.css" />
        <script type="text/javascript" src="cadastroTurma.js"></script>
        <title>JSP Page</title>
    </head>
    <body>
        <h1>CADASTRO DE TURMA!</h1>
        <form id="divTurma" name="FormCadastroTurma" action="respostacadastroTurma.jsp" method="post">
            <jsp:useBean id="pegaCursos" scope="page" class="org.neg.curso.Curso" />
            <jsp:useBean id="pegaUsuarios" scope="page" class="org.neg.usuario.Usuario" />
            <%
                out.write("<input type=\"hidden\" name=\"idCurso\" value=\"" + request.getParameter("idCurso") + "\"></input>");
            %>
            Horario:<br><input type="text" name="horario"><p>
            Data:<br>
            <select name="ano" onchange="mostraMes()" style="width: 55px">
            <%
                int i = Calendar.getInstance().get(Calendar.YEAR);
                while(i >= 1900){
                    out.write("<option value=\"" + i + "\" >" + i + "</option>\n");
                    i--;
                }
            %>
            </select>
            <select name="mes" onchange="mostraDias()" disabled="disabled" style="width: 40px">
            <%
                for(int j = 1; j <= 12; j++){
                    if(j < 10)
                        out.write("<option value=\"0" + j + "\" >0" + j + "</option>\n");
                    else
                        out.write("<option value=\"" + j + "\" >" + j + "</option>\n");
                }
            %>
            </select>
            <select name="dia" disabled="disabled" style="width: 40px">
            <%
                for(int j = 1; j <= 28; j++){
                    if(j < 10)
                        out.write("<option value=\"0" + j + "\" >0" + j + "</option>\n");
                    else
                        out.write("<option value=\"" + j + "\" >" + j + "</option>\n");
                }
            %>
            </select> <p>
            Sala:<br><input type="text" name="sala" /><p>
            Instrutor:<br><input type="text" name="instrutor" /><p>
            Alunos:<br><select name="listaAlunos" multiple="multiple">
                <%
                    //ResultSet rstAlunos = pegaUsuarios.getUsuarios();
                    if(request.getParameter("idCurso") != null){
                        int cursoEscolhido = Integer.parseInt(request.getParameter("idCurso"));
                        ResultSet rstAlunos = pegaCursos.getInscritosDoCurso(cursoEscolhido);
                        while(rstAlunos.next())
                            out.write("<option value=\""+rstAlunos.getString("IdUsuario") +"\">"+rstAlunos.getString("Nome") +"</option>\n");
                    }
                %>
            </select>
            <select name="listaSelecionados" multiple="multiple">
            </select>
            <div id="botoes">
                <input type="button" id="btnListas" onclick="Adiciona()" value=">">
                <input type="button" id="btnListas" onclick="AdicionaTodos()" value=">>">
                <input type="button" id="btnListas" onclick="RemoveTodos()" value="<<">
                <input type="button" id="btnListas" onclick="Remove()" value="<">
            </div>
            <p>
            <input id="btnSetLocal" type="submit" value="OK" onclick="selecionaTodos('listaSelecionados')" />   
            <br>Campos com asterisco(*) são obrigatórios.
        </form>
    </body>
</html>